home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 19
/
CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso
/
CUCD
/
Utilities
/
Scion
/
ARexx
/
Unrelated.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-11-04
|
7KB
|
255 lines
/****************************************************************************
* *
* $VER: Unrelated 1.03 (12 Oct 1997)
* *
* Written by Robbie Akins *
* *
* Adapted from ARexx scripts by Freddy Ariës - Many thanks Freddy :-) *
* *
* ARexx script to find "unrelated" people in the database. *
* That is, it will locate all those people who have no parents and who *
* have no marriages recorded (and hence cannot have any recorded children) *
* *
* This script uses (by default) the rexxreqtools.library (which requires *
* a version of reqtools larger than 2.0 and rexxsyslib.library) *
* If you do not have these, run SetDefaults.rexx to change the settings. *
* *
* 1.02: Now uses preference file for default settings (by Freddy Ariës) *
* 1.03: Now supports v5 commands GETFIRSTIRN/GETNEXTIRN/GETLASTIRN *
* *
****************************************************************************/
options results
arg outname outval
versionstr = "1.03"
/* Don't change the settings here! Run SetDefaults.rexx instead! */
usereq = 1; pscr = "SCIONGEN"
outp = 1; output = stdout; scrdev = stdout
scrname = "CON:0//639//Scion Output/AUTO/SCREEN"
NL = '0A'x
signal on IOERR
/* parse command line options, to enable calling the script automatically,
* eg. from a function key
*/
do while outname = '?'
writeln(stdout, "OUTFILE/A,QUIET/S,NOREQ/S ")
pull outname outval
end
/* read preferences file */
if open(pfile, 'ENV:Scion/ScionRexx.prefs', 'r') then do
do while ~eof(pfile)
inln = readln(pfile)
if inln ~= "" then do
wstr = upper(word(inln, 1))
if wstr = "USEREQ" then
usereq = 1
else if wstr = "NOUSEREQ" then
usereq = 0
else if wstr = "PUBSCREEN" then
pscr = strip(delstr(inln, 1, length(wstr)), 'b', ' "')
end
end
close(pfile)
end
if pscr = "" | (pscr ~= "WORKBENCH" & ~show('p', pscr)) then
pscr = "SCIONGEN"
scrname = scrname||pscr
/* command line options get priority over global settings */
if outname ~= "" then do
if outname = "QUIET" | outname = "NOREQ" then do
outval = outname; outname = ""
end
end
if outval = "QUIET" then do
outp = 0; usereq = 0
end
else if outval = "NOREQ" then usereq = 0
if ~show('l','rexxarplib.library') then do
if exists('libs:rexxarplib.library') then
call addlib('rexxarplib.library',0,-30,0)
end
screentofront(pscr)
if usereq & ~show('l','rexxreqtools.library') then do
if exists('libs:rexxreqtools.library') then
call addlib('rexxreqtools.library',0,-30,0)
else do
usereq = 0; outp = 1
Tell("Unable to open rexxreqtools.library - using text output")
end
end
/* These first few lines were stolen from Peter Billings - thanks Peter ;-) */
if ~show('P','SCIONGEN') then do
EndString('I am sorry to say that the SCION Genealogist' || NL ||,
'database is not available. Please start the' || NL ||,
'SCION program BEFORE using this script!')
end
myport = "SCIONGEN"
address value myport
GETDBNAME
dbname = upper(RESULT)
CurrIRN = 1
if outp & ~usereq then do
if pscr ~= "WORKBENCH" then do
scrdev = 'SCNLNKSCR'
if ~open(scrdev, scrname, 'w') then scrdev = stdout
end
Tell("Scion Unrelated Person Finder v"||versionstr||" by Robbie Akins")
Tell("Current Scion database: "||dbname)
end
if (prgvers >= 5) then
do
GETFIRSTIRN
CurrIRN = RESULT
GETLASTIRN
TotalIRN = RESULT
end
else do
GETTOTALIRN
TotalIRN = RESULT
CurrIRN = 1
end
if TotalIRN = 0 then
EndString("No database loaded - exiting...") /* No database to work on! */
/* It's a good habit to add an ".UNREL" extension to "unrelated" files */
dblen = length(dbname)
if dblen>6 & right(dbname, 6)=".Scion" then dbname=left(dbname, dblen - 6)
if outname = "" then do
if outp then do
if usereq then do
odev = rtezrequest('Current Scion database: '||dbname||,
NL||'Where should the output be sent to?'||,
NL,' _File |_Printer|_Screen|_Nowhere','Unrelated People v'||versionstr||' by Robbie Akins','rt_pubscrname = '||PSCR)
select
when odev = 1 then do
/* We need a file requester for further data */
outname = rtfilerequest(,dbname||'.UNREL','Output filename',,'rtfi_buffer = true rt_pubscrname = '||PSCR||' rtfi_initialpath = RAM:',)
if outname = '' then
outname = dbname||'.UNREL'
end
when odev = 2 then
outname = 'PRT:'
when odev = 3 then
outname = 'STDOUT'
otherwise
EXIT
/* You selected 'Nowhere' */
end
end
else do
Tell("Enter output file (filename with complete path, or PRT: for printer,")
TellNN("or STDOUT for screen): ")
outname = readln(scrdev)
outname = strip(outname, 'b', ' "')
Tell("Destination: "||outname)
TellNN("Continue (y/n)? ")
conf = readln(scrdev)
conf = upper(left(conf, 1))
/* Note that left works on empty strings ("") too! */
if conf ~= "Y" then
EndString("Goodbye...")
Tell("")
end
end
else
outname = "RAM:"dbname".UNREL"
/* If we're not allowed to use stdout, default to this filename */
end
if outname ~= "STDOUT" then do
output = 'OUTPUT'
if ~open(output, outname, "w") then
EndString("ERROR: Unable to open output file.")
end
else
output = scrdev
writeln(output, "List of unrelated people:")
do while (CurrIRN > 0) & (CurrIRN <= TotalIRN)
EXISTPERSON CurrIRN
if RESULT = 'YES' then do
GETNUMMARRY CurrIRN
if RESULT = 0 then do
/* No marriages. Possible candidate */
GETPARENTS CurrIRN
if RESULT = '' then do
/* This person is unrelated */
GETLASTNAME CurrIRN
last = result
GETFIRSTNAME CurrIRN
first = result
str = "IRN" CurrIRN": "Last", "First
writeln(output, str)
end
end
end
/* Do next possible person */
if (prgvers >= 5) then
do
GETNEXTIRN CurrIRN
CurrIRN = RESULT
end
else do
CurrIRN = CurrIRN + 1
end
end
EndString("Done.")
EXIT
Tell: PROCEDURE EXPOSE outp scrdev
parse arg str
if outp then writeln(scrdev, str)
return 0
TellNN: PROCEDURE EXPOSE outp scrdev
parse arg str
if outp then writech(scrdev, str)
return 0
EndString: PROCEDURE EXPOSE outp output usereq scrdev pscr
parse arg str
/* If you turned off stdout, no error messages will be shown! */
if usereq then
rtezrequest(str,'E_xit','Finder Message:','rt_pubscrname = '||pscr)
else do
Tell(str || '0A'x)
end
if outp & ~usereq & (scrdev ~= stdout) then do
Tell("Press <return> to exit.")
readln(scrdev)
close(scrdev)
end
close(output)
EXIT
IOERR:
bline = SIGL
say "I/O error #"||RC||" detected in line "||bline||":"
say sourceline(bline)
EXIT